import java.util.Arrays;

public class test {
    //利用for-each对数组进行遍历，for-each循环中X代表冒号后数组中的元素
    public static void main(String[] args) {
        int[][] array = {{6,8,9},{6,8,9}};
        for (int[] array2:array){
            for(int x:array2){
                System.out.print(x+" ");
            }
            System.out.println();
        }
        System.out.println();
        String ret = Arrays.deepToString(array); //二维数组快捷打印方法
        //String ret = Arrays.TOString(array)  一维数组快捷打印方式
        System.out.println(ret);
    }
    //定义二维数组
    public static void main1(String[] args) {
        int[][] array = {{1,2,3},{4,5,6}};
        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};
        int[][] array3 = new int[2][3];//行不可以省略，列可以省略
        System.out.println(array[1][1]);
        System.out.println();
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]+" ");
            }
        }
        System.out.println();
        System.out.println("行数："+array.length);
        System.out.println("列数："+array[1].length);
        /*for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array[i][j]+" ");
            }
        }*/
    }
}
